import java.net.*;
import java.io.*;
public class Urlstatus  {

	/**Author:Savita
	 * Feb 05,2009
	 * This program returns the Http status code & response message of a Url.
	 **/
	private int responseCode;
	private URL responseURL;
	private String responseMessage;
	private java.util.Map<String,java.util.List<String>> responseHeader = null;
	public Urlstatus(String urlstring)throws MalformedURLException, IOException
	{
		URL url=new URL(urlstring);
		URLConnection ucon=url.openConnection();
		HttpURLConnection con=(HttpURLConnection)ucon;
		con.setConnectTimeout( 10000 );
		con.setReadTimeout( 10000 );
		con.setInstanceFollowRedirects( true );
		con.setRequestProperty( "User-agent", "spider" );
		con.connect();
		responseHeader= con.getHeaderFields( );
        responseCode= con.getResponseCode( );
        responseMessage=con.getResponseMessage();
        responseURL= con.getURL( );
               
     }
	
	
	public int getResponseCode() {
		return responseCode;
	}
	public void setResponseCode(int responseCode) {
		this.responseCode = responseCode;
	}
	public java.util.Map<String, java.util.List<String>> getResponseHeader() {
		return responseHeader;
	}
	public void setResponseHeader(
			java.util.Map<String, java.util.List<String>> responseHeader) {
		this.responseHeader = responseHeader;
	}
	public URL getResponseURL() {
		return responseURL;
	}
	public void setResponseURL(URL responseURL) {
		this.responseURL = responseURL;
	}


	public String getResponseMessage() {
		return responseMessage;
	}


	public void setResponseMessage(String responseMessage) {
		this.responseMessage = responseMessage;
	}

}
